# AUTHOR: DING
# -*- codeing = utf-8 -*-
# @Time: 2024/2/23 13:28
# @Author: 86139
# @Site: 
# @File: 13-poolLayer.py
# @Software: PyCharm
# tensorboard --logdir=pytorch/logs --port=6007

import torch
import torch.nn as nn
import torchvision
from torch.nn import MaxPool2d
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter

dataset = torchvision.datasets.CIFAR10("./dataset", train=False, transform=torchvision.transforms.ToTensor(),
                                       download=True)
dataLoader = DataLoader(dataset, batch_size=64, drop_last=True)


class MyModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.pool1 = MaxPool2d(kernel_size=3, ceil_mode=True)

    def forward(self, x):
        x = self.pool1(x)
        return x


module = MyModule()
writer = SummaryWriter("./logs")
step = 0
for data in dataLoader:
    imgs, targets = data
    writer.add_images("input_pool", imgs, step)
    output = module(imgs)
    writer.add_images("output_pool", output, step)
    step += 1
writer.close()
